
#ifndef _TTG_PIPELINE_NODESTATE_
#define _TTG_PIPELINE_NODESTATE_
#include "Common/Definitions.h"

#include "Runtime.Low/Threads.h"

namespace ttg_internal
{
	namespace pipeline
	{
		//Represents state of node.
		enum ProcessingState
		{
			Begined = 0,		//it's started, data can be processed
			Ended = 1			//it's ended, data cannot be processed
		};
		//Contains information about current state (e.g. count of active inputs,
		//unperformed task, etc)
		//
		//Difference between NodeState and NodeInfo:
		//NodeState contains current information, that is needed for pipeline work
		//and can be changed during iteration.
		//NodeInfo contains statistics, that is used by external essences.
		class NodeState
		{
			private:
				int input_count;			//count of inputs.
				int active_inputs;			//count of inputs, that are still working.
				int active_tasks;			//count of unperformed tasks.
				ProcessingState state;		//is begined/ended?
				ttg::threads::FastCriticalSection locker;
			public:
				//Creates default state.
				NodeState();
				//Returns total count of connected nodes.
				inline int &getInputCount()
				{ return input_count; }
				//Returns count of active (working) inputs.
				inline int &getActiveInputCount()
				{ return active_inputs; }
				//Returns count of active tasks.
				inline int &getActiveTaskCount()
				{ return active_tasks; }
				//Returns data processing state (begined/ended).
				inline ProcessingState &getProcessingState()
				{return state; }
				//Returns locker for this node state.
				inline ttg::threads::FastCriticalSection &getLocker()
				{ return locker; }
		};
	}
}

#endif
